package com.otsdemo.controller;

import com.otsdemo.common.Result;
import com.otsdemo.entity.Course;
import com.otsdemo.entity.Homework;
import com.otsdemo.service.OrderService;
import com.otsdemo.service.StudentService;
import com.otsdemo.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @Autowired
    private TeacherService courseService;

    @Autowired
    private OrderService orderService;


    @GetMapping("/getCourse")
    public Result getCourseList() {
        List<Course> courses = studentService.getCourseList();
        return Result.suc(courses);
    }

    @PostMapping("/selectCourses")
    public Result selectCourse(@RequestParam Integer studentId, @PathVariable Integer courseId) {
        return studentService.selectCourse(studentId,courseId)?Result.suc():Result.fail();
    }

    @PostMapping("homework")
    public Result submitHomework(@RequestParam Homework homework){
        return studentService.submitHomework(homework)?Result.suc():Result.fail();
    }

}